<div class="panel">
  <%= render_message do %>
    <p><%= Alchemy.t(:homepage_does_not_exist) %></p>
  <% end %>

  <%- if @languages_with_page_tree.size >= 1 -%>
    <%= form_tag(alchemy.copy_language_tree_admin_pages_path) do %>
      <h3><%= Alchemy.t(:copy_language_tree_heading) %></h3>
      <p><%= Alchemy.t(:want_to_make_copy_of_existing_language) %></p>
      <div class="input select">
        <%= label_tag('languages[old_lang_id]', Alchemy.t('Language tree'), class: 'control-label') %>
        <%= select_tag("languages[old_lang_id]", options_for_select(@languages_with_page_tree.map{ |l| [l.name, l.id] }), is: "alchemy-select") %>
        <%= hidden_field_tag("languages[new_lang_id]", @language.id) %>
      </div>
      <div class="submit">
        <%= button_tag Alchemy.t(:copy) %>
      </div>
    <% end %>
  <%- end -%>

  <%= alchemy_form_for([:admin, Alchemy::Page.new], id: 'create_language_tree') do |form| %>
    <% if @languages_with_page_tree.size >= 1 %>
      <h3><%= Alchemy.t(:create_language_tree_heading) %></h3>
      <p><%= Alchemy.t(:want_to_create_new_language) %></p>
    <% end %>
    <%= form.input :name, input_html: {value: @language.frontpage_name} %>
    <%= form.input :page_layout,
      collection: @page_layouts,
      selected: @language.page_layout,
      label: Alchemy.t(:page_type),
      include_blank: Alchemy.t('Please choose'),
      required: true,
      input_html: {is: 'alchemy-select'} %>
    <%= form.hidden_field :language_id, value: @language.id %>
    <%= form.hidden_field :language_code, value: @language.code %>
    <%= form.hidden_field :language_root, value: true %>
    <%= form.hidden_field :public, value: Alchemy::Language.all.size == 1 %>
    <%= form.submit Alchemy.t(:create), autofocus: true %>
  <% end %>
</div>
